<template>
    <el-cascader class="search-cascader"
        v-model="option.value"
        size="small"
        :filterable="filterable"
        :options="option.options"
        :show-all-levels="option.showAllLevels"
        :popper-class="option.popperClass"
        collapse-tags
        :props="option.optionProps"
        @visible-change="blurSearchItem(option, index, $event)"
        @change="changeSelectSearchItem">
    </el-cascader>
</template>

<script>
import normalMixin from "../mixin/normalMixin";
export default {
    name: "searchCascader",
    mixins: [normalMixin],
    methods: {
        /**
         * Cascader 组件 change 事件触发
         * @param {Array|String} value time 组件返回数据
         */
        changeSelectSearchItem(value) {
            if (this.option.closeRelevanceName) this.$emit('closeUse', this.option.closeRelevanceName);
            if (this.option.changeMethod) this.option.changeMethod(value);
        }
    },
    computed: {
        filterable() {
            return this.option.optionProps?.multiple ? !this.option.optionProps?.multiple : true;
        }
    }
}
</script>
